/*
 * $Id: rwl.h,v 1.1 2005-12-15 06:52:13 bacon Exp $
 */

#ifndef _XP_BAS_RWL_H_
#define _XP_BAS_RWL_H_

#include <xp/types.h>
#include <xp/macros.h>
#include <xp/bas/mtx.h>
#include <xp/bas/cond.h>

struct xp_rwl_t
{
	xp_mtx_t  mtx;
	xp_cond_t rcond;
	xp_cond_t wcond;

	xp_size_t rwait_count;
	xp_size_t wwait_count;
	xp_size_t ractive_count;
	xp_size_t wactive_count;

	xp_bool_t __dynamic;
};

typedef struct xp_rwl_t xp_rwl_t;

#ifdef __cplusplus
extern "C" {
#endif

xp_rwl_t* xp_rwl_open (xp_rwl_t* rwl);
void xp_rwl_close (xp_rwl_t* rwl);

int xp_rwl_lockr (xp_rwl_t* rwl);
int xp_rwl_trylockr (xp_rwl_t* rwl);
int xp_rwl_unlockr (xp_rwl_t* rwl);

int xp_rwl_lockw (xp_rwl_t* rwl);
int xp_rwl_trylockw (xp_rwl_t* rwl);
int xp_rwl_unlockw (xp_rwl_t* rwl);

#ifdef __cplusplus
}
#endif


#endif
